# fibonacci_with_cache.py

def fibonacci_with_cache():
    cache = {}

    def fibonacci(n):
        if n in cache:
            return cache[n]
        if n <= 1:
            return n
        result = fibonacci(n-1) + fibonacci(n-2)
        cache[n] = result
        return result

    return fibonacci

fib = fibonacci_with_cache()
n = 10
print(f"斐波那契数列第{n}项：{fib(n)}")